package xinxin.com.FlyweightPatternBasic.Factory;

import xinxin.com.FlyweightPatternBasic.Flyweight.Concrete.ConcreteFlyweight;
import xinxin.com.FlyweightPatternBasic.Flyweight.Flyweight;

import java.util.Hashtable;

/**
 * @author ：史鑫鑫
 * @date ：Created in 2019/4/2 21:33
 */
public class FlyweightFactory {
    private Hashtable flyweights = new Hashtable();

    public FlyweightFactory() {
        this.flyweights.put("X", new ConcreteFlyweight());
        this.flyweights.put("Y", new ConcreteFlyweight());
        this.flyweights.put("Z", new ConcreteFlyweight());
    }

    public Flyweight GetFlyweight(String key) {
        return (Flyweight)flyweights.get(key);
    }
}
